home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Utilities ƒ / MPW Tools ƒ / Simula4.07 / Simula 4.07ƒ / SInterfaces / macMenuBar.sim < prev    next >
Encoding:
Text File  |  1989-05-01  |  3.6 KB  |  141 lines  |  [TEXT/MPS ]

  1. % ---------------------------------------------------------------------------
  2. %    Class MACMenuBar
  3. %
  4. % In this module you find the programmers interface to Menus.
  5. % It is built on top of the toolbox routines in toolboxmenus.
  6. % For a description of the routines see Inside Macintosh, chapter 9.
  7. %
  8. % 890317/Boris Magnusson
  9. % 890330/Göran Eriksson
  10. % ---------------------------------------------------------------------------
  11. external class MacMenu="::SInterfaces:MacMenu";
  12. external class MacPoint="::SInterfaces:MacPoint";
  13. external class toolboxmenu="::SInterfaces:toolboxmenu";
  14.  
  15. simset class MACMenuBar;
  16.     virtual: procedure doMenu is
  17.         procedure doMenu(menuid,item); integer menuid,item;;
  18. begin
  19.     ref(toolboxMenu) Trap;
  20.     integer MenuBarHandle;
  21. ! ----------------------;
  22.  
  23.     procedure doMenu(menuid,item); integer menuid,item;
  24.         inspect findMenu(Menuid) do
  25.             doMenu(Menuid,item);
  26.     
  27.     PROCEDURE InitMenus;
  28.         Trap.ToolboxInitMenus;
  29.  
  30.     ref(macMenu) procedure FindMenu(Menuid); integer MenuId;
  31.         inspect findNotice(Menuid) do
  32.             FindMenu:-aMenu;
  33.             
  34. %        FUNCTION GetNewMBar(menuBarID: INTEGER): Handle;
  35.     procedure GetNewMBar(menuBarID);
  36.         short integer menuBarID;
  37.         begin        
  38.             MenuBarHandle:=TRAP.ToolboxGetNewMBar(menuBarID);
  39.             ! build all list here and in each menu !!! ;
  40.         end;
  41.  
  42. %        PROCEDURE InsertMenu(menu: MenuHandle; beforeId: INTEGER);
  43.     PROCEDURE InsertMenu(menu, beforeId);
  44.         ref(MacMenu) menu;
  45.         short integer beforeId;
  46.         begin
  47.             ref(menuNotice) N;
  48.             TRAP.toolboxInsertMenu(menu.menuHandle, beforeId);
  49.             n:-findNotice(beforeId);
  50.             if N=/=none then
  51.                 new MenuNotice(menu).precede(N)
  52.             else
  53.                 new MenuNotice(menu).into(MenuQ);
  54.         end;
  55.  
  56. %        PROCEDURE DeleteMenu(menuId: INTEGER);
  57.     PROCEDURE DeleteMenu(menuId);
  58.         short integer menuId;
  59.         begin
  60.             findNotice(MenuId).out;
  61.             TRAP.toolboxDeleteMenu(menuId);
  62.         end;
  63.  
  64.     PROCEDURE DrawMenuBar;
  65.         TRAP.toolboxDrawMenuBar;
  66.  
  67.     PROCEDURE ClearMenuBar;
  68.     begin
  69.         TRAP.toolboxClearMenuBar;
  70.         MenuQ.clear;
  71.     end;
  72.  
  73. %        FUNCTION MenuSelect(startPt: Point): LONGINT;
  74.     integer procedure MenuSelect(startPt);
  75.         ref(MacPoint) startPt;
  76.         MenuSelect:=TRAP.toolboxMenuSelect(startPt.h,startPt.v);
  77.  
  78. %        FUNCTION MenuKey(ch: CHAR): LONGINT;
  79.     integer procedure MenuKey(ch);
  80.         character ch;
  81.         MenuKey:=TRAP.toolboxMenuKey(ch);
  82.  
  83. %        FUNCTION GetMenuBar: Handle;
  84. %    procedure GetMenuBar;
  85. %        begin
  86. %            theMenuList:=ToolboxGetMenuBar;
  87. %        end;
  88.  
  89. %        PROCEDURE SetMenuBar(menuList: Handle);
  90. %    PROCEDURE SetMenuBar(aMenuBar);
  91. %     ref(MacMenubar) aMenuBar;
  92. %     ToolboxSetMenuBar(aMenuBar.theMenuList);
  93.  
  94. %        PROCEDURE HiliteMenu(menuId);
  95.     PROCEDURE HiliteMenu(menuId);
  96.         short integer menuId;
  97.         TRAP.toolboxHiliteMenu(menuId);
  98.  
  99. %        PROCEDURE SetMenuFlash(flashCount: INTEGER);
  100.     PROCEDURE SetMenuFlash(flashCount);
  101.         short integer flashCount;
  102.         TRAP.toolboxSetMenuFlash(flashCount);
  103.  
  104. %        PROCEDURE FlashMenuBar(menuId: INTEGER);
  105.     PROCEDURE FlashMenuBar(menuId);
  106.         short integer menuId;
  107.         TRAP.toolboxFlashMenuBar(menuId);
  108.  
  109. %        FUNCTION GetMHandle(menuId: INTEGER): MenuHandle;
  110. %    ref(MacMenu) procedure GetMHandle(menuId);
  111. %        short integer menuId;
  112. %        begin
  113. %            TRAP.toolboxGetMHandle(menuId);
  114. %            GetMHandle:-FindElementWith(menuId);
  115. %        end;
  116. ! --------- Local routines -------- ;
  117.  
  118.     link class MenuNotice(aMenu); ref(macmenu) aMenu;;
  119.     ref(Head) MenuQ;
  120.     ref(MenuNotice) procedure findNotice(id); integer id;
  121.     begin
  122.         ref(MenuNotice) p;
  123.         p:-MenuQ.first;
  124.         while p=/=none and then p.aMenu.Menuid<>Id do
  125.             p:-P.suc;
  126.         findNotice:-p;
  127.     end;
  128.         
  129.     integer procedure ostype(thetext);text thetext;
  130.     begin ostype:=rank(thetext.getchar)*16R1000000+
  131.         rank(thetext.getchar)*16R10000+
  132.         rank(thetext.getchar)*16R100+
  133.         rank(thetext.getchar);
  134.     end;
  135.     
  136. ! --- Init -- ;
  137.  
  138.     TRAP:-new toolboxmenu;
  139.     MenuQ:- new Head;
  140. end --- Mac Menu Bar ---;